package com.zuipin.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zuipin.entity.product.CategoryInfo;
import com.zuipin.framework.annotation.Json;
import com.zuipin.framework.annotation.Valid;
import com.zuipin.framework.annotation.Valids;
import com.zuipin.framework.emuns.ErrorCode;
import com.zuipin.framework.result.Result;
import com.zuipin.service.ICategoryInfoService;
import com.zuipin.vo.BackCatIdPropertyVo;
import com.zuipin.vo.CategoryInfoVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * 品类信息Controller
 *
 * @ClassName CategoryInfoController
 * @author wangcongyi
 * @date 2017年4月19日 下午5:41:20
 */

@Controller
@RequestMapping(value = "/proCat")
@Api(value = "品类信息", description = "品类信息-wangcongyi")
public class CategoryInfoController {
	
	@Resource
	private ICategoryInfoService categoryInfoService;
	
	@RequestMapping(value = "/queryCatTree", method = RequestMethod.GET)
	@ApiOperation(value = "518-查找品类信息树-wangcongyi", notes = "查找品类信息树")
	@ResponseBody
	
	@Valids({ @Valid(name = "sysId", required = false) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "sysId", value = "系统ID 如果为空或者0则查询通用的品类树信息", required = false, dataType = "long", paramType = "query") })
	public Result<List<CategoryInfoVo>> queryCatTree(@RequestParam(value = "sysId", required = false) Long sysId) {
		Result<List<CategoryInfoVo>> result = new Result<>();
		result.setData(categoryInfoService.findRootCategoryInfo(sysId));
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
	@Json(type = CategoryInfo.class, include = "id,parentId,catName,catLevel")
	@RequestMapping(value = "/queryCatNav", method = RequestMethod.GET)
	@ApiOperation(value = "518-查找品类导航-wangcongyi", notes = "查找品类导航")
	@Valids({ @Valid(name = "catId", required = true) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "catId", value = "品类ID", required = true, dataType = "long", paramType = "query") })
	public Result<List<CategoryInfo>> queryCatNav(@RequestParam(required = true) Long catId) {
		Result<List<CategoryInfo>> result = new Result<>();
		result.setData(categoryInfoService.findCategoryNav(catId));
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
	/**
	 * 创建子分类(基础分类 展示分类)
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/createCateInfo", method = RequestMethod.GET)
	@ApiOperation(value = "创建子分类", notes = "创建子分类 ")
	@Valids({})
	@ApiImplicitParams({
			
			@ApiImplicitParam(name = "categroyName", value = "分类名称", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "title", value = "分类标题", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "keyword", value = "分类关键字", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "parentId", value = "父级ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "catSeq", value = "分类排序", required = true, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "createId", value = "创建者", required = true, dataType = "long", paramType = "query") })
	public Result createCateInfo(@RequestParam(value = "categroyName") String categroyName, @RequestParam(value = "title") String title,
			@RequestParam(value = "keyword") String keyword, @RequestParam(value = "parentId") Long parentId, @RequestParam(value = "catSeq") Integer catSeq,
			@RequestParam(value = "createId") Long createId) {
		
		return null;
	}
	
	/**
	 * 更新分类信息
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/updateCateInfo", method = RequestMethod.GET)
	@ApiOperation(value = "更新分类信息", notes = "更新分类信息 ")
	@Valids({})
	@ApiImplicitParams({ @ApiImplicitParam(name = "categroyName", value = "分类名称", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "title", value = "分类标题", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "keyword", value = "分类关键字", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "parentId", value = "父级ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "catId", value = "分类ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "catSeq", value = "分类排序", required = true, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "updateId", value = "更新者", required = true, dataType = "long", paramType = "query") })
	public Result updateCateInfo(@RequestParam(value = "catId") Long catId, @RequestParam(value = "categroyName") String categroyName, @RequestParam(value = "title") String title,
			@RequestParam(value = "keyword") String keyword, @RequestParam(value = "parentId") Long parentId, @RequestParam(value = "catSeq") Integer catSeq,
			@RequestParam(value = "updateId") Long updateId) {
		
		return null;
	}
	
	/**
	 * 更新(基础 展示)分类的状态
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/modifyCateInfoState", method = RequestMethod.GET)
	@ApiOperation(value = "更新基础分类的状态", notes = "更新基础分类的状态 ")
	@Valids({})
	@ApiImplicitParams({ @ApiImplicitParam(name = "catId", value = "分类ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "state", value = "状态", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "updateId", value = "更新者", required = true, dataType = "long", paramType = "query") })
	public Result modifyCateInfoState(@RequestParam(value = "catId") Long catId, @RequestParam(value = "state") String state, @RequestParam(value = "updateId") Long updateId) {
		return null;
	}
	
	@ResponseBody
	@RequestMapping(value = "/selectProCategoryProperty", method = RequestMethod.POST)
	@ApiOperation(value = "后台(查询)通用商品品类通用属性VO", notes = "查询品类下通用属性")
	@Valids({})
	public Result<List<BackCatIdPropertyVo>> selectProCategoryProperty(@RequestParam Long catId) {
		// 看属性是选择的还是手写的 选择的要给出选择项目
		return null;
	}
	
}
